﻿@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/Shared/_Index_Layout.cshtml";
    ViewFWUser currentUserInfo = base.Context.Session.GetUserInfo();
}
@if (currentUserInfo.IsHaveRights("Demo_Student2Course", "00"))
{
@section styles{
}
@section scripts{
    @*<script src="~/js/views/Main/Home/index.js" asp-append-version="true"></script>*@
}

<table id="myDg"></table>
<div id="myDg-toolbar" data-options="grid:{
            type:'edatagrid',
            id:'myDg'
        }" class="topjui-toolbar">

    @if (currentUserInfo.IsHaveRights("Demo_Student2Course", "01"))
    {
        <a href="javascript:void(0)"
            data-toggle="topjui-menubutton"
            data-options="method:'edatagrid',
            extend: '#myDg-toolbar',
            iconCls:'fa fa-plus',
            btnCls:'topjui-btn-export',
            type:'addRow'">@L("新增")</a>
    }

    <a href="javascript:void(0)"
        data-toggle="topjui-menubutton"
        data-options="method:'edatagrid',
        extend: '#myDg-toolbar',
        iconCls:'fa fa-save',
        btnCls:'topjui-btn-brown',
        type:'saveRow'">@L("保存")</a>

    <a href="javascript:void(0)"
        data-toggle="topjui-menubutton"
        data-options="method:'edatagrid',
        extend: '#myDg-toolbar',
        iconCls:'fa fa-remove',
        btnCls:'topjui-btn-black',
        type:'cancelRow'">@L("取消")</a>

    @if (currentUserInfo.IsHaveRights("Demo_Student2Course", "02"))
    {
        <a href="javascript:void(0)"
               data-toggle="topjui-menubutton"
               data-options="method:'edatagrid',
               extend: '#myDg-toolbar' ,
               iconCls:'fa fa-remove',
               btnCls:'topjui-btn-blue',
               type:'destroyRow'">@L("删除")</a>
    }
   
    <a href="javascript:void(0)"
        data-toggle="topjui-menubutton"
        data-options="method:'filter',
        extend: '#myDg-toolbar',
        btnCls:'topjui-btn-filter'">@L("过滤")</a>

    <a href="javascript:void(0)"
           data-toggle="topjui-menubutton"
           data-options="
           method:'search',
           extend: '#myDg-toolbar',
           btnCls:'topjui-btn-query'">@L("查询")</a>
</div>

<script>

    var dg = $('#myDg').iEdatagrid({
        idField: 'id',
        url: '/api/services/app/DemoStudent2Course/GetGridDto',
        reloadAfterSave: false,
        saveUrl: '/api/services/app/DemoStudent2Course/CreateByDto',
        updateUrl: '/api/services/app/DemoStudent2Course/UpdateByDto',
        destroyUrl: '/api/services/app/DemoStudent2Course/DeleteByDto',
        queryParams: {
            order: 'CreateTime  desc',
            viewName: 'view_Demo_Student2Course'
        },
        columns: [
            [
                {
                    field: 'id',
                    title: 'id',
                    checkbox: true,
                },

                {
                    field: 'courseGUID',
                    title: '@L("课程GUID")',
                    width: 120,
                    sortable: true,
                    editor: {
                        type: 'combobox',
                        options: {
                            editable: true,
                            valueField: 'id',
                            textField: 'text',
                            loader: $.loader.comboxLoader,
                            mode: 'remote',
                            queryParams:
                            {
                                viewName: 'View_Demo_course',
                                comBoxValueName: 'courseName'
                            }
                        }
                    }
                },

                {
                    field: 'studentGUID',
                    title: '@L("学生GUID")',
                    width: 120,
                    sortable: true,
                    editor: {
                        type: 'combobox',
                        options: {
                            editable: true,
                            valueField: 'id',
                            textField: 'text',
                            loader: $.loader.comboxLoader,
                            mode: 'remote',
                            queryParams:
                            {
                                viewName: 'View_Demo_student',
                                comBoxValueName: 'studentName'
                            }
                        }
                    }
                },

                {
                    field: 'score',
                    title: '@L("分数")',
                    width: 120,
                    sortable: true,
                    formatter: $.ei.moneyFormatter,
                    editor: { type: 'numberbox', options: { required: false, height: 30, precision: 2 } }
                },

            ]
        ],
        frozenColumns: [[

        ]],
        filter: [
            {
                field: 'score',
                type: 'numberbox',
                op: ['equal', 'notequal', 'less', 'lessorequal', 'greater', 'greaterorequal'],
                options: {
                    precision: 2
                }
            },


        ],
        onDblClickRow: function () {

        }
    });
</script>
}
else
{
    <h1>@L("你没有该页面的权限")</h1>
}

